perm filename BAZ.LSP[W81,JMC] blob sn#617739 filedate 1981-10-10 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	 finding a path from x to y
C00003 ENDMK
CāŠ—;
;;; finding a path from x to y

(defun findpath (x y) (fp1 (list x) y nil))

(defun fp1 (u y path) (cond
		       ((null u) 'lose)
		       ((member (car u) path) (fp1 (cdr u) y path))
		       ((equal (car u) y) (reverse (cons y path)))
		       (t ((lambda (w) (cond
					((eq w 'lose) (fp1 (cdr u) y path))
					(t w)))
			   (fp1 (successors (car u)) y (cons (car u) path))))))